package Majisuka
{
	public class People
	{
		protected var _hp:int ; // 总血量
		protected var _att:int ; // 攻击力
		protected var _def:int ; // 防御力
		protected var _currHp:int ; // 当前血量
		protected var _group:int ; // 所属团队
		protected var _id:int ; // 人物id
		protected var _name:String ; // 人物名称
		protected var _where:int ; // 人物所在地id
		protected var _icon:String ; // 人物头像
		protected var _sinaId:String ; // 新浪微博的Id
			
		public function People()
		{
		}

		public function get sinaId():String
		{
			return _sinaId;
		}

		public function set sinaId(value:String):void
		{
			_sinaId = value;
		}

		public function get icon():String
		{
			return _icon;
		}

		public function set icon(value:String):void
		{
			_icon = value;
		}

		public function get id():int
		{
			return _id;
		}

		public function set id(value:int):void
		{
			_id = value;
		}

		public function get where():int
		{
			return _where;
		}

		public function set where(value:int):void
		{
			_where = value;
		}

		public function get name():String
		{
			return _name;
		}

		public function set name(value:String):void
		{
			_name = value;
		}

		public function get group():int
		{
			return _group;
		}

		public function set group(value:int):void
		{
			_group = value;
		}

		public function get currHp():int
		{
			return _currHp;
		}

		public function set currHp(value:int):void
		{
			_currHp = value;
		}

		public function get def():int
		{
			return _def;
		}

		public function set def(value:int):void
		{
			_def = value;
		}

		public function get att():int
		{
			return _att;
		}

		public function set att(value:int):void
		{
			_att = value;
		}

		public function get hp():int
		{
			return _hp;
		}

		public function set hp(value:int):void
		{
			_hp = value;
		}

		public function Save():XML
		{
		// Generate a XML object which contains the information of this player 
			var x:XML ;
			x = <people>
					<hp>{_hp}</hp>
					<att>{_att}</att>
					<def>{_def}</def>
					<currHp>{_currHp}</currHp>
					<group>{_group}</group>
					<name>{_name}</name>
					<where>{_where}</where>
					<icon>{_icon}</icon>
					<sinaId>{_sinaId}</sinaId>
				</people> ;
			return x ;
		}
		
		public function Load( id:int, x:XML ):void
		{
			// Load item "id" from the xml file
			_id = id ;
			_hp = int( x.hp ) ;
			_att = int( x.att ) ;
			_def = int( x.def ) ;
			_currHp = int( x.currHp ) ;
			_group = int( x.group ) ;
			_name = x.name ;
			_where = int( x.where ) ;
			_icon = x.icon ;
			_sinaId = x.sinaId ;
		}
		
		public function RestoreHp( h:int ):void
		{
			_currHp += h ;
			if ( _currHp > _hp )
				_currHp = _hp ;
		}
		
		public function Fatigue( h:int ):void 
		{
			// Reduce hp due to activities like move to another place
			_currHp -= h ;
			if ( _currHp < 0 )
				_currHp = 0 ;
		}
		
		public function GetFighterInfo( f:Fighter ):void
		{
			_currHp = f.currHp ;
		}
	}
}